<?php
/**
 * [商网通 System] Copyright swtshop.cn
 * QQ: 1170787711
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied');
class admin extends module
{
    function __construct()
    {
        $this->aid = @$_SESSION['admin']['aid'];
        parent::__construct();
    }
    public function index()
    {
        $m = isset($_GET['m']) ? $_GET['m'] : 'index';
        $a = isset($_GET['a']) ? $_GET['a'] : 'index';
        $this->jq_time = !empty($_GET['jq_time']) ? $_GET['jq_time'] : false;
        if ($this->aid != '1') {
            if ($m != 'index') {
                $str = @$_SESSION['admin']['power_con'];
                if (empty($str)) {
                    error_json('您当前无任何权限');
                } else {
                    $p_mod = explode('@', $str);
                    if (isset($p_mod)) {
                        foreach ($p_mod as $v) {
                            $aaa = explode(':', $v);
                            if (isset($aaa[1])) {
                                $action_arr[$aaa[0]] = explode(',', $aaa[1]);
                            }
                        }
                        if (isset($action_arr)) {
                            if (isset($action_arr[$m])) {
                                if (!in_array($a, $action_arr[$m])) {
                                    $this->back_error();
                                }
                            } else {
                                $this->back_error();
                            }
                        } else {
                            $this->back_error();
                        }
                    } else {
                        $this->back_error();
                    }
                }
            }
        }
        if ($m == 'index' && $a == 'index' || $m == 'index' && $a == 'login_submit' || $m == 'index' && $a == 'vcode') {
        } else {
            if (!$_SESSION['admin']['aid']) {
                header("Location:?");
            }
        }
    }
    private function back_error()
    {
        if ($this->jq_time) {
            error_json('没有权限操作');
        } else {
            $html = '
				<style>
				h1{ width:100%; height:100%; font-size:16px; vertical-align: middle;  }
				h1 i{ width:20px; height:20px; background:#FF0000;   }
				h1 span{ color:#f00; font-family:Microsoft Yahei;  }
				</style>
				<h1><span>没有权限操作</span></h1>
			';
            exit($html);
        }
    }
    public function admin_auth()
    {
        if (!$_SESSION['admin']['aid']) {
            header("Location:?");
        }
    }
}